<?php
class TvbOrbitDistributor extends BaseDistributor {
	
	public function getDestinationId() {
		return 2;
	}

	public function distribute(array $data) {
		return TRUE;
	}
	
	public function getVideo($export_id) {
		$rf = VideoInfrastructure::GetReadableRecordFactory();
		
		$found = $rf->find(
			'Distribution',
			'export_id=? AND destination_id=?',
			array($export_id, $this->getDestinationId())
		);
		
		if (!$found) {
			return -2;	// Export video not found
		}
		
		$distribution_entry = array_shift($found);
		
		if ($distribution_entry->status != 1) {
			return $distribution_entry->status; // Video is not ready
		}
		
		$other_info = json_decode($distribution_entry->other_info, TRUE);
		
		return $other_info;
	}
	
	public function getVideoListBySourceId($source_id) {
	}
}

$distributor = new TvbOrbitDistributor();
$ret = DistributorFactory::getInstance()->register($distributor->getDestinationId(), $distributor);
?>
